<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.study.system.user.domain.User" %>
<%@ page import="com.study.system.user.service.impl.UserServiceImpl" %>
<%@ page import="com.study.system.user.domain.UserDept" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" deferredSyntaxAllowedAsLiteral="true" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>打卡系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-admin-theme.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-admin-theme.css">

    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap-dropdown.min.js"></script>
</head>
<%--导入js--%>
<script src="${pageContext.request.contextPath}/static/js/axios-0.18.0.js"></script>
<script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>


<body class="bootstrap-admin-with-small-navbar">
<%@include file="admin_header.jsp" %>

<%--提示信息--%>
<%
    Object message = request.getAttribute("message");
    if (message != null && !"".equals(message)) {

%>

<script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
</script>
<%} %>

<div class="container">
    <div class="row">
        <%@include file="admin_means.jsp" %>
        <!-- content -->
        <div class="col-md-10">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="text-muted bootstrap-admin-box-title">打卡管理系统</div>
                        </div>
                        <div class="bootstrap-admin-panel-content">
                            <form action="${pageContext.request.contextPath}/user/updateInformation2" method="post">
                                <table>
                                    <div style="display: none">id<input type="text" name="uid" id="uid"
                                                                        value="${userDept.id}"></div>
                                    <div style="display: none">status<input type="text" name="status" id="status"
                                                                            value="1"></div>
                                    <tr>
                                        <td>员工姓名：</td>
                                        <td><input type="text" name="updatename" id="updatename"
                                                   value="${userDept.name}"></td>
                                    </tr>
                                    <tr>
                                        <td>员工部门：</td>
                                        <td>
                                            <select name="updatedept" id="updatedept">
                                                <!--下拉列表框-->
                                                <option value="1" selected="selected">研发部</option>
                                                <option value="2">销售部</option>
                                                <option value="3">办公室</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <table>
                                        <tr>
                                            <td>
                                                <div class="buttons">
                                                    <input value="修 改" type="submit" id="upd_btn" name="upd_btn_a">
                                                </div>
                                            </td>

                                            <td>
                                                <div class="buttons">
                                                    <input value="取 消" type="reset" id="set_btn">
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script>
    function updataInfo() {
        var updatename = document.getElementById("updatename").value;
        var updatedept = document.getElementById("updatedept").value;
        // 将表单数据转为json

        alert("dsdas")
        alert(${user.id})
        alert(${user.date})
        alert(${user.username})
        var values = {
            id:${user.id},
            name: updatename,
            date:${user.date},
            deptid: updatedept,
            username:${user.username},
            password:${user.password},
        };


        alert(values.id)
        axios({
            method: "POST",
            url: "${pageContext.request.contextPath}/user/updateInformation",
            data: values
        }).then(function (resp) {
            if (resp.data = true) {
                alert("修改信息成功,请重新登陆!")
                location.href = "${pageContext.request.contextPath}/jsp/login.jsp";
            } else {
                alert("修改失败!")
                location.href = "${pageContext.request.contextPath}/jsp/user/user_index.jsp";
            }
        })
    }
</script>
</body>
</html>